function ajax(url,data,s,f){
  wx.request({
    url: url,
    data:data,
    method: "post",
    header: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    success: function (res) {
  
      s&&s(res);
    },
    fail:function(res){
      f&&f(res)
    }
  })
}



//输入e和要获取的键返回键对应的值
function getdata(e){
 return e.currentTarget.dataset
}
//星座检测输入年月日格式为2011-11-12
function checkxingzuo(a) {
  var arr = a.split("-")
  switch (arr[1]*1) {
    case 1:
      return arr[2] <= 19 ? "摩羯座" : "水瓶座121";
      break;
    case 2:
      return arr[2] <= 18 ? "水瓶座" : "双鱼座";
      break;
    case 3:
      return arr[2] <= 20 ? "双鱼座" : "白羊座";
      break;
    case 4:
      return arr[2] <= 19 ? "白羊座" : "金牛座";
      break;
    case 5:
      return arr[2] <= 20 ? "金牛座" : "双子座";
      break;
    case 6:
      return arr[2] <= 21 ? "双子座" : "巨蟹座";
      break;
    case 7:
      return arr[2] <= 22 ? "巨蟹座" : "狮子座";
      break;
    case 8:
      return arr[2] <= 22 ? "狮子座" : "处女座";
      break;
    case 9:
      return arr[2] <= 23 ? "处女座" : "天秤座";
      break;
    case 10:
      return arr[2] <= 23 ? "天秤座" : "天蝎座";
      break;
    case 11:
      return arr[2] <= 22 ? "天蝎座" : "射手座";
      break;
    case 12:
      return arr[2] <= 21 ? "射手座" : "摩羯座";
      break;
  }
}
function verlogin(){
  if (wx.getStorageSync('userInfo') == '') {
    wx.showToast({
      title: '请先登录',
      icon: 'none'
    })
    setTimeout(function () {
      wx.navigateTo({
        url: '/pages/login/index',
        success: function (res) { },
        fail: function (res) { },
        complete: function (res) { },
      })
    }, 1000)
    return;
  };
  return;
}

module.exports={
  ajax:ajax,
  checkxingzuo:checkxingzuo,
  getdata:getdata,
  verlogin: verlogin
}